import React, { Component } from 'react'

export default class setstate extends Component {
    state ={count:0}
    count=()=>{
        //const {count}=this.state
        //对象式setState
        // this.setState({count:count+1},()=>{
        //  //setState是异步的此函数是setState走完之后调用可选可不选
        // })
        //函数式setState
        // this.setState((state,props)=>{
        //     return {count:state.count+1}
        // })
        //简化
        this.setState(state=>({count:state.count+1}))
    }
    render() {
        return (
            <div>
                he:{this.state.count}
                <button onClick={this.count}>jia</button>
            </div>
        )
    }
}
